package cn.myschool.pojo;

/**
 * @author oldliu
 * @since 1.0
 */
//for ajax
public class AjaxResult {
    private int code;//0：表示成功，其他值含义。。。404,500,403重复了。。。
    private String msg;
    private Object data;//传递的数据
    public AjaxResult(){

    }

    public AjaxResult(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public AjaxResult(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    public static AjaxResult success(){
        return new AjaxResult(0,null);
    }
    public static AjaxResult success(Object data){
        return new AjaxResult(0,null,data);
    }
    public static AjaxResult error(){
        return new AjaxResult(400,null);
    }
    public static AjaxResult error(String msg){
        return new AjaxResult(400,msg);
    }
    public static AjaxResult error(int code,String msg){
        return new AjaxResult(code,msg);
    }

    public int getCode() {
        return code;
    }
    public boolean isSuccess(){
        return code == 0;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
